export class CommonUtil {
  static onlyKey(): string {
    let symbol = Symbol()
    return symbol.toString()
  }

  static hasProperty<T extends Object>(obj: T, propName: string): boolean {
    return propName in obj
  }

  /**
   * 是否为二维数组
   * @param range 参数
   * @returns
   */
  static isNestedArray(range: any | undefined): boolean {
    if (!range) {
      return false;
    }
    const isNestedArray = Array.isArray(range) && (range as Array<Object>).every((item) => {
      return Array.isArray(item)
    })
    return isNestedArray;
  }

  static isTextCascadePickerRangeContent(range: any | undefined): boolean {
    if (!range) {
      return false;
    }
    const isPickerRangeContent = Array.isArray(range) && range.every((item) => {
      return typeof item === 'object' &&
        item !== null &&
        'text' in item &&
        'children' in item &&
      Array.isArray(item.children);
    });
    return isPickerRangeContent;
  }
}

